var curlClass = function () {
    this.url = "";
    this.params = {
    };
}

curlClass.prototype.ajax = function (uri, method, data, dataType, async, callback, ex) {
    if (async === undefined) async = true;

    let contentType = dataType === 1 ? 'application/json;charset=UTF-8' : 'application/x-www-form-urlencoded';
    if (dataType === 1) {
        data = JSON.stringify(data);
    }

    $.ajax({
        type: method,
        data: data,
        url: uri,
        dataType: 'json',
        contentType: contentType,
        async: async,
        beforeSend: function () {
        },
        success: function (res) {
            callback(res);
        },
        error: function (xhr,status,error) {
            console.log(error);
            ex(error);
        }
    })
};

curlClass.prototype.post = function (uri, data, dataType, async, callback, ex) {
    this.ajax(uri, 'post', data, dataType, async, callback, ex);
}

curlClass.prototype.get = function (uri, data, async, callback, ex) {
    this.ajax(uri, 'get', data, undefined, async, callback, ex);
}
var curl = new curlClass();